package com.xj.sbd.es.controller;

import com.xj.sbd.es.feign.LoginFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xj.sbd.es.test.TestInterface;

import java.util.HashMap;
import java.util.Map;

//@ResponseBody
//@Controller
@RefreshScope
@RestController
public class HelloEsController {



    // nacos config
    @Value("${es.user.name}")
    private String name;
    @Value("${es.user.age}")
    private Integer age;
    @RequestMapping("/nacos_config")
    public Map<String, Object> nacos_config() {
        //return "name:"+name+" "+ "age: "+age;

        Map<String, Object> map = new HashMap();
//        User user = new User(1, "倪升武", "123456");
        map.put("作者信息", name);
        map.put("年龄", age);

        return map;
    }

    @Value("${es.user.ver}")
    private String ver;
    @RequestMapping("/ver")
    public String isVer(){
        return ver + " 夏迹.com@ es# ..";
    }

    // test interface
    @Autowired
    TestInterface testInterface;
    @RequestMapping("/test_interface")
    public String test(){
       return testInterface.test_interface();
    }


    @Autowired
    LoginFeignService loginFeignService;

    @RequestMapping("/getlogin")
    public String getLogin(){
//        System.out.println(loginFeignService.isLogin());
        return loginFeignService.isLogin();
    }

    @RequestMapping("/demo-es")
    public String helloEs(){
        return "夏迹.com@ es# ..";
    }
}
